<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:py="http://purl.org/kid/ns#"
    py:extends="'master.kid'">

<head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type" py:replace="''"/>
    <title>YourBase.com.br - Painel de Controle</title>

<style type="text/css" media="screen">
@import "/static/css/style.css";
</style>
<script type="text/javascript">

function row_display(info) {
    //log(info);
    return TR(null, map(tr_display, info));
    }

function tr_display(val) {
    return TD(null, val);
    }

LoadInfo = {

    start: function(e) {
        LoadInfo._nodeid = e.target().id.substring(5);  
        log("Verificando info para: " + LoadInfo._nodeid );
        e.preventDefault();
        replaceChildNodes("show_" + LoadInfo._nodeid + "_status",
            STRONG("Carregando.."));
        var d = loadJSONDoc("${tg.url('/painel/status/')}" +
            LoadInfo._nodeid);
        d.addCallback( function (result) {
        log("Informacoes carregadas. Substituindo div: ", LoadInfo._nodeid)
        var currentvps_status = TABLE(null, map(row_display,
        result["vpsinfo"]));
        replaceChildNodes("show_" + LoadInfo._nodeid + "_status", currentvps_status);
    });},
};

function connect_click(node) {
        connect(node,'onclick', LoadInfo.start );
};
addLoadEvent(function() {
        var nodes = getElementsByTagAndClassName("A", "vps_status");
        map(connect_click, nodes);
    
});
</script>
</head>

<body>
<div id="sidebar">
<p>- <a href="${tg.url('/logout')}"> Logoff</a></p>
</div>
<a href="/painel">Painel de controle</a> &gt; Gerência de servidores<br/><br/>
<br/><br/>
<p py:content="tabber()">Painel Servidores</p>

<div class="tabber">
    <div py:for="server in servers" class="tabbertab">
    <h2>${server.domain}</h2>
   <br/> 
    <table >
    <tr><td > Domínio:</td><td >${server.domain}</td>
        <td py:if="server.rimuid != None" rowspan="15"><a
        id="info_${server.domain}" class="vps_status"
        href="${tg.url('/painel/status/%s' % server.domain)}">Verificar status</a>
        <div id="show_${server.domain}_status">
        </div>
        </td>
        </tr>
    <tr><td>IP Principal</td><td>${server.main_ip}</td></tr>
    <tr><td>Plano:</td><td><a
    href="/planos#${server.plan.planname}">${server.plan.planname}</a></td></tr>
    <tr><td>Memória:</td><td>${server.memory_mb} Mb</td></tr>
    <tr><td>Disco:</td><td>${server.disk_gb} Gb</td></tr>
    <tr><td>Transferência mensal<br/>
            permitida:</td><td>${server.transfer_gb}
            Gb</td></tr>
    <tr><td>Painel de Controle:</td><td>${server.panel.name}</td></tr>
    <tr><td>Distribuição:</td><td>${server.distro.name}</td></tr>
    <tr><td>Mensalidade:</td><td>${tg.real(server.price_real)}</td></tr>
    <tr><td>Faturas pendentes:</td><td>
        <?python
        def notpaid(i):
            return not i.paid
            
        unpaid = [i for i in server.invoices if notpaid(i) ]

        if len(unpaid) == 0:
            pending = "Não"
        else:
            pending = '<span class="fielderror"><a \
            href="%s">Sim</a></span>' % tg.url('/painel/pagamento') 
            ?>
            ${XML(pending)}
</td></tr>
    </table>
    <br/><br/>

    <table py:if="server.rimuid != None" padding="20px">   
    <tr><td width="50%">
    <div style="padding-right: 20px">
    <strong>Reinicializar o servidor</strong>
    <p>Equivale a um control+alt+del na console. Os processos
    serão gentilmente encerrados. O sistema de arquivos será 
    desmontado e terá seus dados sincronizados no disco antes do
    desligamento.</p>
    <br/>
        <form action="/painel/reboot">
    <input type="hidden" name="domain" value="${server.domain}"/>
    <input class="submit" type="submit" value="Soft Reboot"/>
    </form>
    </div>
    </td>
    <td>
    <div style="padding-right: 20px">
    <strong>Desligar/Ligar o servidor</strong>
    <p>Equivale a um apertar o botão de <em>reset</em> do servidor. 
    O sistema será imediamente fechado, com risco de perda de
    dados. Utilize apenas se o soft reboot não tiver funcionado.</p>
    <br/>
        <form action="/painel/reboot">
    <input type="hidden" name="domain" value="${server.domain}"/>
    <input type="hidden" name="hard" value="1"/>
    <input class="submit" type="submit" value="Hard Reboot"/>
    </form>
    </div>
    </td></tr></table>
</div>


</div>

</body>
</html>

